home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / prog / swin_0_1.zip / SOBJECTS.INC < prev    next >
Text File  |  1993-03-29  |  4KB  |  173 lines

  1. Unit sObjects;
  2.  
  3. Interface
  4.  
  5. Uses Graph,sObj2,sTypes,Mouse,Crt;
  6.  
  7. Const
  8.   ws_Border=1;
  9.   ws_Title=2;
  10.   ws_Maximize=4;
  11.   ws_System=8;
  12.   ws_Display=16;
  13.  
  14. Type
  15.  
  16.   PsWindow=^TsWindow;
  17.   TsWindow=object(TsObject)
  18.     Attr:TsAttr;
  19.     Parent,Current:PsWindow;
  20.     Title:PChar;
  21.     Repaint,Maximize,Close:Boolean;
  22.     Constructor Init(sParent:PsWindow;sTitle:String;sX,sY,sW,sH:Word);
  23.     Destructor Done; virtual;
  24.     Procedure SetUpWindow; virtual;
  25.     Procedure Paint; virtual;
  26.     Procedure DeleteChildren; virtual;
  27.     Procedure Clear; virtual;
  28.     Procedure Event(evX,evY:Word;var Msg:Byte); virtual;
  29.     Procedure HandleEvent(evX,evY:Word;var Msg:Byte); virtual;
  30.     Procedure PaintUp; virtual;
  31.   End;
  32.  
  33.   PsApplication=^TsApplication;
  34.   TsApplication=object(TsObject)
  35.     MainWindow:PsWindow;
  36.     Constructor Init;
  37.     Destructor Done; virtual;
  38.     Procedure InitMainWindow; virtual;
  39.     Procedure Run; virtual;
  40.   End;
  41.  
  42.   PsView=^TsView;
  43.   TsView=object(TsObject)
  44.     Attr:TsAttr;
  45.     Constructor Init(sX,sY,sW,sH:Word;sFT,sColor:Byte);
  46.   End;
  47.  
  48.   PsFrame=^TsFrame;
  49.   TsFrame=object(TsView)
  50.     Procedure SetUpWindow; virtual;
  51.   End;
  52.  
  53.   PsDisplay=^TsDisplay;
  54.   TsDisplay=object(TsView)
  55.     Procedure SetUpWindow; virtual;
  56.   End;
  57.  
  58.   PsTitle=^TsTitle;
  59.   TsTitle=object(TsView)
  60.     Title:PChar;
  61.     Procedure SetTitle(T:PChar); virtual;
  62.     Procedure SetUpWindow; virtual;
  63.   End;
  64.  
  65.   PsMaximize=^TsMaximize;
  66.   TsMaximize=object(TsView)
  67.     Procedure SetUpWindow; virtual;
  68.   End;
  69.  
  70.   PsSystem=^TsSystem;
  71.   TsSystem=object(TsView)
  72.     Procedure SetUpWindow; virtual;
  73.   End;
  74.  
  75.  
  76. Implementation
  77.  
  78.   Procedure TsTitle.SetTitle(T:PChar);
  79.  
  80.        Sets the title for the title bar.
  81.  
  82.   Constructor TsApplication.Init;
  83.  
  84.        Goes into graphics mode.  Looks for driver path from env. var. BGI.
  85.        Initializes the mouse and called InitMainWindow
  86.  
  87.   Destructor TsApplication.Done;
  88.  
  89.        Disposes of MainWindow and closes the graphics mode.
  90.  
  91.   Procedure TsApplication.InitMainWindow;
  92.  
  93.        Calls the MainWindow's Paint Method.
  94.        When overridden, it is important to call this method after your
  95.        new method.
  96.  
  97.   Procedure TsApplication.Run;
  98.  
  99.        Checks for Mouses Events and passes them to the MainWindow.
  100.        MainWindow will in turn pass the events down until some window
  101.        uses it.  If not, it will  be passed back up the parents and then
  102.        they can use it.  The smallest child gets the event first.
  103.        If overridden, call MainWindow^.Event and check if MainWindow^.Close
  104.        is true before exiting.
  105.  
  106.   Procedure TsWindow.HandleEvent(evX,evY:Word;var Msg:Byte);
  107.  
  108.        Sorts out the events and does their functions.  Handles maximize,
  109.        selection, close.
  110.  
  111.   Procedure TsWindow.Event(evX,evY:Word;var Msg:Byte);
  112.  
  113.        Keeps track and handles the repainting of windows to avoid unnecessary
  114.        repainting.
  115.  
  116.   Procedure TsWindow.PaintUp;
  117.  
  118.        Same here.
  119.  
  120.   Procedure TsWindow.Paint;
  121.  
  122.        Draws the window and all children.  If this is overridden, it also
  123.        needs to be called.
  124.  
  125.   Constructor TsView.Init(sX,sY,sW,sH:Word;sFT,sColor:Byte);
  126.  
  127.        Initializes variables.
  128.  
  129.   Procedure TsDisplay.SetUpWindow;
  130.  
  131.        Draws window.
  132.  
  133.   Procedure TsMaximize.SetUpWindow;
  134.  
  135.        Draws Maximize Button.
  136.  
  137.   Procedure TsSystem.SetUpWindow;
  138.  
  139.        Draws System Button.
  140.  
  141.   Procedure TsTitle.SetUpWindow;
  142.  
  143.        Draws Title Bar
  144.  
  145.   Procedure TsFrame.SetUpWindow;
  146.  
  147.        Draws Frame
  148.  
  149.   Procedure TsWindow.SetUpWindow;
  150.  
  151.        Calls all the pieces to be drawn.
  152.  
  153.   Constructor TsWindow.Init(sParent:PsWindow;sTitle:String;sX,sY,sW,sH:Word);
  154.  
  155.        Sets up variables, Creates child list, Sets Parent pointer, adds self
  156.        to parent's child list, Calls TsObject.Init
  157.  
  158.   Procedure TsWindow.DeleteChildren;
  159.  
  160.       Disposes of all children and their children....
  161.  
  162.   Procedure TsWindow.Clear;
  163.  
  164.       Clears the window and sets the viewport to whole screen.
  165.  
  166.   Destructor TsWindow.Done;
  167.  
  168.       Calls DeleteChildren, Dispose of Window List, Clear the window.
  169.       Deletes self from parent's child list.  Calls parent to paint.
  170.       Calls TsObject.Done
  171.  
  172. Begin
  173. End.